(function() {
    class Animal {
        name:String;
        age:number;
        //constructor在创建对象时调用
        constructor(name:String,age:number){
        //this表示当前对象
        this.name = name ;
        this.age = age;
        }
        sayhello(){
            console.log('XXX');
        }
    }
    //如果子类中有和父类相同的方法，子类方法会覆盖父类方法---方法重写
    class Dog extends Animal{
        run(){
            console.log('${this.name}run');
        }

        sayhello(){
            console.log('汪汪汪');
        }
    }
    const dog=new Dog('旺财',1);
    dog.sayhello();
    dog.run();





})();